/*"""
@Version: V1.0
@Author: willson.wu
@License: Apache Licence
@Contact: willson.wu@goertek.com
@Site: goertek.com
@Software: GoLand
@File: main.go
@Time: 18-12-26 下午5:57
*/

package datebase

import (
	"fmt"
	"gopkg.in/mgo.v2"
	"os"
)

// 定义Mongo链接对象，全局变量
var MongoClient *mgo.Database

// 初始化mongo客户端，即初始化链接对象
func init() {
	session, err := mgo.Dial("127.0.0.1:27017")
	if err != nil {
		fmt.Println("Mongo connection is error:", err)
		os.Exit(-1)
	}
	db := session.DB("agv")
	MongoClient = db
}

func main() {
	c := MongoClient.C("s")
	fmt.Println(c)
	//c.Update(bson.M{"s"})
}
